/*!
 * \file es_init.c
 *
 * \brief es 解析模块初始化
 *
 * All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.\n
 * ct管理用共通函数
 *
 * \version 4.0
 * \author geyh
 * \date 2016/08/29
 *
 */
#include <stdio.h>
#include "conntrack.h"
#include "module.h"
#include "frlog.h"

#include "config.h"
#include "es_core.h"

//框架的上下文引用
void *g_p_apm_context=NULL;

#ifdef  __cplusplus
extern "C"
{
#endif

/*!
 * es 模块加载
 *
 * \p_context                      (服务器上下文)
 * \p_module_params                (模块加载 参数)
 * \p_module_cfg                   (配置信息)
 *
 * \return FR_FAIL:失败
 *         FR_SUCC:成功
 *
 */
int module_init(void *p_context, const char* p_module_params, L7_module_config *p_module_cfg)
{
    int i_ret = FR_SUCC;

    if(p_context == NULL || p_module_cfg == NULL)
        return FR_FAIL;

    g_p_apm_context = p_context;
    if( fr_slab_init( (Frmem_env *)(((ApmContext *)g_p_apm_context)->p_st_mem_env), MODULE_NAME) == NULL )
        return FR_FAIL;

    frlog_set_hd(((ApmContext *)g_p_apm_context)->p_st_log_category);
    p_module_cfg->p_l4_proto = MODULE_L4PROTO;
    p_module_cfg->i_l7_proto = MODULE_L7PROTO;
    p_module_cfg->p_module_name = MODULE_NAME;
    p_module_cfg->p_version = MODULE_VERSION " " MODULE_TIME;
    p_module_cfg->l7_detect = es_detect;
    p_module_cfg->l7_analysis = es_analysis;
    p_module_cfg->session_destory = es_session_destroy;

    return FR_SUCC;
}

/*!
 * es 模块卸载
 *
 * \return      void
 *
 */
void module_exit(void)
{
    fr_slab_destroy();
    return;
}

#ifdef  __cplusplus
}
#endif
